package FriendTable.Gui;
/*
更新A
 */
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

public class MainPanel extends JPanel {
    public JTextArea friendsList;

    public MainPanel() {
        setLayout(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();

        friendsList = new JTextArea();
        friendsList.setEditable(false);
        friendsList.setLineWrap(true);
        friendsList.setWrapStyleWord(true);
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.weightx = 1;
        gbc.weighty = 1;
        add(friendsList, gbc);

        JSeparator separator = new JSeparator(SwingConstants.HORIZONTAL);
        gbc.gridy = 1;
        add(separator, gbc);

        JPanel buttonsPanel = new JPanel();
        buttonsPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
        JButton displayAllButton = new JButton("显示所有");
        displayAllButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                FriendGUI.displayFriends();
            }
        });
        buttonsPanel.add(displayAllButton);
        gbc.gridy = 2;
        add(buttonsPanel, gbc);
    }
}